<%@ page session="false" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  
<html>
	<head>
		<META NAME="Description" CONTENT="Sorteo del Amigo Invisible via email. Disponible en múltiples lenguajes. Available in multiple languages.">
		<title><fmt:message key="form.title.1"/></title>
    	<link rel="stylesheet" type="text/css"  href="css/common.css" />


    <!--[if lt IE 5.5000]><style type="text/css">@import "css/IE50Fixes.css"; @import "css css/skinIE55Fixes.css";</style><![endif]-->
    <!--[if IE 5.5000]><style type="text/css">@import "css/IE55Fixes.css"; @import "css/skinIE55Fixes.css";</style><![endif]-->
    <!--[if gte IE 6]><style type="text/css">@import "css/IE60Fixes.css"; @import "css/skinIE60Fixes.css";</style><![endif]-->
    
		<script type="text/javascript" src="js/dynamic-forms.js"></script>
		<script type="text/javascript">
			function valida(){
				var last=true;
				var error="";
				var amigos=0;
				for (i=ind;i>0;i--){
					var name=document.getElementById("name_"+i);
					var email=document.getElementById("email_"+i);
					var exclude=document.getElementById("exclude_"+i);
					
					if (name.value=="" && email.value=="" && exclude.value==""){
						if (last==false) {
							tmperror="<fmt:message key='form.val.amigo.emptyrow'><fmt:param value='$i'/></fmt:message>\n";
							error+=tmperror.replace("$i",i);
						}						
					} else
					if (name.value=="" || email.value==""){
						tmperror="<fmt:message key='form.val.amigo.emptyfield'><fmt:param value='$i'/></fmt:message>\n";
						error+=tmperror.replace("$i",i);
						if (isNaN(exclude.value)){
							tmperror="<fmt:message key='form.val.amigo.exclude'><fmt:param value='$i'/></fmt:message>\n";
							error+=tmperror.replace("$i",i);
						}
						last=false;
					} else {
						if (!(email.value.indexOf('.') >= 1 && email.value.indexOf('@') >= 2)){
							tmperror="<fmt:message key='form.val.amigo.email'><fmt:param value='$i'/></fmt:message>\n";
							error+=tmperror.replace("$i",i);
						}
						if (isNaN(exclude.value)){
							tmperror="<fmt:message key='form.val.amigo.exclude'><fmt:param value='$i'/></fmt:message>\n";
							error+=tmperror.replace("$i",i);
						}
						last=false;
						amigos++;
					}
				}
				
				if (amigos<3) error+="<fmt:message key='form.val.amigo.min'/>";
				if (amigos>75) error+="<fmt:message key='form.val.amigo.max'/>";
				
				if (error=="") return true;
				alert(error);
				return false;
			}
			
			function recupera_alert(){
				t=prompt("<fmt:message key="form.ticket"/>");
				if (t != '' && t != null) {		
					ticket=document.getElementById('ticket');
					ticket.value=t;
					document.getElementById('recupera').submit();
				}
			}
			
		</script>
		
<!-- PUT THIS TAG IN THE head SECTION -->
<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js">
</script>
<script type="text/javascript">
  GS_googleAddAdSenseService("ca-pub-4210362751776017");
  GS_googleEnableAllServices();
</script>
<script type="text/javascript">
  GA_googleAddSlot("ca-pub-4210362751776017", "BannerTop540x100");
</script>
<script type="text/javascript">
  GA_googleFetchAds();
</script>
<!-- END OF TAG FOR head SECTION -->
		
	</head>
	<body class="ns-0">
	
	  <div style="position: absolute;top: 10px;right: 0px;background-repeat: no-repeat;background-position: left bottom;">
	    <ul style="padding: 2px;float: right;clear: both;margin-bottom: 1em;display: inline;margin-right: 74px;">
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><fmt:message key='form.lang'/></li>
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=es">ES</a> |</li>
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=eu_ES">EU</a> |</li>
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=ca_es">CA</a> |</li>
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=en">EN</a> |</li>
	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=fr">FR</a> |</li>
 	    	<li style="display: inline;margin:0px;padding:0px;font-size: 0.9em;"><a href="index.htm?siteLanguage=it">IT</a></li>
	    </ul>
	  </div>
	<div id="CabeceraBanner" align="center">

<!-- PUT THIS TAG IN DESIRED LOCATION OF SLOT BannerTop540x100
     -->
<script type="text/javascript">
  GA_googleFillSlot("BannerTop540x100");
</script>
<!-- END OF TAG FOR SLOT BannerTop540x100
     -->

	</div>	  
        <div id="globalWrapper">
        <div id="content">
		<h1 class="firstHeading"><fmt:message key="form.welcome"/></h1>
        <div id="column-content">
	<div id="bodyContent">
	    <div id="contentSub"></div>
	
		
	    	<div style="border: 1px solid #6eb927; padding: .7em; background-color:#ecf2e6; margin-top: 0;">
			<fmt:message key="form.step1"/>
			<div align="right">
			<form id="recupera" action="recupera.htm">
				<input type="hidden" name="ticket" id="ticket">
				<a href="javascript:recupera_alert()"><fmt:message key="form.recuperar"/></a>
			</form>
			</div>
		</div>

		
		<form method="post" onsubmit="return valida();">
		<div id="errors">
		<spring:bind path="amigo">
			<ul>
				<c:forEach items="${status.errorMessages}" var="errorMessage">
					<li style="color:red"><c:out value="${errorMessage}"/></li>
				</c:forEach>
			</ul>
		</spring:bind>
		</div>
				
			<table id="main" style="border: 1px solid #aaa; margin: 0; padding: 0; width: 100%;">
				<tr>
					<td style="vertical-align:top; width: 70%; padding-right: .6em;">
						<div class="hp_box">
						<table id="listaAmigos">	
						
							<tr >
								<td colspan="4" style="padding: 10pt"><label><fmt:message key="form.instr.mails"/></label></td>
							</tr>
							<tr>
								<td colspan="4"><a href="javascript:addAmigo()"><fmt:message key="form.add"/></td>
							</tr>
							
							<tr>
								<td style="font-size: 90%; text-align: center;"><fmt:message key="form.col.id"/></td>
								<td style="font-size: 90%; text-align: center;"><fmt:message key="form.col.name"/></td>
								<td style="font-size: 90%; text-align: center;"><fmt:message key="form.col.mail"/></td>
								<td style="font-size: 90%; text-align: center;"><fmt:message key="form.col.exclude"/></td>
								<td style="font-size: 90%; text-align: left;"><a href="faq.htm#inst" target="_blank"><img src="help.gif"/></a></td>
							</tr>
							
							<tr id="am_1">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="1"/>
									<td>1</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name" id="name_1"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email" id="email_1"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" id="exclude_1" size="2" maxlength="2"/></td>
								</spring:bind>
							</tr>
			
							<tr id="am_2">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="2"/>
									<td>2</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name" id="name_2"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email" id="email_2""/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_2"/></td>
								</spring:bind>
							</tr>
							
							<tr id="am_3">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="3"/>
									<td>3</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name"  id="name_3"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email"  id="email_3"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_3"/></td>
								</spring:bind>
							</tr>
	
							<tr id="am_4">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="4"/>
									<td>4</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name"  id="name_4"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email"  id="email_4"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_4"/></td>
								</spring:bind>
							</tr>
	
							<tr id="am_5">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="5"/>
									<td>5</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name"  id="name_5"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email"  id="email_5"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_5"/></td>
								</spring:bind>
							</tr>
	
							<tr id="am_6">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="6"/>
									<td>6</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name"  id="name_6"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email"  id="email_6"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_6"/></td>
								</spring:bind>
							</tr>
	
							<tr id="am_7">
								<spring:bind path="amigo.id">
									<input type="hidden" name="id" value="7"/>
									<td>7</td>
								</spring:bind>
							
								<spring:bind path="amigo.name">
									<td><input type="text" name="name"  id="name_7"/></td>
								</spring:bind>
								
								<spring:bind path="amigo.email">
									<td><input type="text" name="email"  id="email_7"/></td>
								</spring:bind>
			
								<spring:bind path="amigo.exclude">
									<td><input type="text" name="exclude" size="2" maxlength="2"  id="exclude_7"/></td>
								</spring:bind>
							</tr>
	
	
			
							<tr id="newAmigoButton">
								<td colspan="4"><a href="javascript:addAmigo()"><fmt:message key="form.add"/></td>
							</tr>
						</table>
						</div>
						
						<table id="submit">	
							<tr>
								<td colspan="2" align="center"><input type="submit" value="<fmt:message key="form.next"/>" name="_target1"/></td>
								<td colspan="2">&nbsp;</td>
							</tr>							
						</table>						
					</td>
					<td width="300" valign="top" align="right" style="width:300px;">
						<script type="text/javascript" charset="utf-8" src="http://www.grouxo.com/widgets/direct/jsiframe/300x250/G3VUZB71L/"></script>
					</td>
				</tr>

				
			</table>


		
		</form>		
		<%@ include file="footer.jsp" %>
		
	</div>
	</div>
	</div>
	</div>
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-1906268-1";
    urchinTracker();
</script>
	</body>
</html>